//Get Cookie Function

var cookieLib = {
    getCookie:				function (name) {
        var cname = name + "=";
        var dc = document.cookie;
        if (dc.length > 0) {
            begin = dc.indexOf(cname);
            if (begin != -1) {
                begin += cname.length;
                end = dc.indexOf(";", begin);
                if (end == -1) end = dc.length;
					return dc.substring(begin, end);
            }
        }
        return null;
    },
    
    
    //get all cookie value
    getAllCookieValue:		function () {
        var value = new Array();
        var name = getAllCookieName();
        if (name == null) return null;
        for (i = 0;i < name.length;i ++)
            value[i] = getCookie(name[i]);
        return value;
    },
    
    
    //get all cookie name
    getAllCookieName:		function () {
        var name = new Array();
        var dc = document.cookie;
        var index = 0;
        if (dc.length < 0) return null;
        s = dc.split(";");
        for (i = 0;i < s.length;i ++) {
            if (s[i].indexOf("=") != -1)
                name[index++] = s[i].substring(0, s[i].indexOf("=")).trim();
        }
        if (name == "") return null;
        return name;
    },
    
    
    //Set Cookie Function
    setCookie:				function (name, value, expires, path, domain, secure) {
        document.cookie = name + "=" + value +
        ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
        ((path == null) ? "" : "; path=" + path) +
        ((domain == null) ? "" : "; domain=" + domain) +
        ((secure == null) ? "" : "; secure");
    },
    
    
    //Delete Cookie Function
    delCookie:				function (name,path,domain) {
        if (getCookie(name)) {
            document.cookie = name + "=" +
            ((path == null) ? "" : "; path=" + path) +
            ((domain == null) ? "" : "; domain=" + domain) +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
    },
    
    
    
    //delete all cookie
    delAllCookie:			function (path,domain) {
        var name = getAllCookieName();
        if (name == null) return null;
        for (i = 0;i < name.length;i ++)
            delCookie(name[i],path,domain);
    },
    
    
    isContainName:			function (name) {
        var allName = getAllCookieName();
        for (i = 0;i < allName.length;i ++)
            if (allName[i] == name) return true;
        return false;
    }
    
}